package com.service.system.region.impl;

import com.dao.HatAreaMapper;
import com.dao.HatCityMapper;
import com.dao.HatProvinceMapper;
import com.entity.system.HatArea;
import com.entity.system.HatCity;
import com.entity.system.HatProvince;
import com.service.system.region.RegionService;
import com.util.Const;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class RegionServiceImpl implements RegionService{

    @Autowired
    HatProvinceMapper hatProvinceMapper;

    @Autowired
    HatCityMapper hatCityMapper;

    @Autowired
    HatAreaMapper hatAreaMapper;

    @Override
    public Map<String, Object> findAllProvince() {
        Map<String,Object> map = new HashMap<>();
        List<HatProvince> hatProvinces = hatProvinceMapper.findAllProvince();
        map.put("code", Const.SUCCESS_CODE);
        map.put("message","查询成功");
        map.put("hatProvinces",hatProvinces);
        return map;
    }

    @Override
    public Map<String, Object> findCityByProvince(String provinceId) {
        Map<String,Object> map = new HashMap<>();
        List<HatCity> hatCities = hatCityMapper.findCityByProvince(provinceId);
        map.put("code",Const.SUCCESS_CODE);
        map.put("message","查询成功");
        map.put("hatCities",hatCities);
        return map;
    }

    @Override
    public Map<String, Object> findAreaByCity(String cityId) {
        Map<String,Object> map = new HashMap<>();
        List<HatArea> hatAreas = hatAreaMapper.findAreaByCity(cityId);
        map.put("code",Const.SUCCESS_CODE);
        map.put("message","查询成功");
        map.put("hatAreas",hatAreas);
        return map;
    }
}
